Fix codegen crashes for intersection types and complex list inner types #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Codegen fails when a schema contains intersection types (
allOf) or lists with complex inner types (e.g.list[dict[str, Any]]). Both crash withComplex type must be put through render_type_expr!orUnexpected expression when expecting a type name: DictTypeExpr(...)becauseTypeNameobjects are used directly in f-strings or passed toensure_literal_typewhich only accepts simpleTypeNamevalues.What changed
TypeName.__str__()crash in theRiverIntersectionTypeencoder by wrappingencoder_namewithrender_literal_type(), matching the existing pattern used byRiverUnionType(line 625) andRiverConcreteType(line 654)ensure_literal_typecrash when a list's inner type is a complex expression (e.g.list[dict[str, Any]]) by guarding theListTypeExprmatch to only enter the encoding branch forTypeNameinner types, falling through tolist(x)for composite types that don't need encodingTest plan
Describe what you did to test this change to a level of detail that allows your reviewer to test it